package com.micro.modual.service.impl;

import com.micro.common.MicroResponseCode;
import com.micro.core.exception.BizException;
import com.micro.core.frame.service.impl.AbstractBasicsServiceImpl;
import com.micro.core.resp.RespJson;
import com.micro.modual.entity.SystemConfig;
import com.micro.modual.extension.SystemConfigExtension;
import com.micro.modual.mapper.SystemConfigMapper;
import com.micro.modual.model.bo.systemconfig.SystemConfigBO;
import com.micro.modual.service.SystemConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
*  <h1>系统配置表  实现</h1>
 * @author LevelCoder
 * @version V1.0.0
 * @email LevelCoder@126.com
 * @date 2020-08-04 00:11:10
 */
@Service("systemConfigService")
public class SystemConfigServiceImpl extends AbstractBasicsServiceImpl<SystemConfig,Long> implements SystemConfigService {

    @Autowired
    private SystemConfigMapper systemConfigMapper;

    /**
     * <h2>新增系统配置表详情</h2>
     * @param systemConfigBO {@link SystemConfigBO} 系统配置表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @Override
    public RespJson addSystemConfig(SystemConfigBO systemConfigBO) {
        SystemConfig systemConfig = SystemConfigExtension.converAddSystemConfig(systemConfigBO);
        systemConfigMapper.insertSelective(systemConfig);
        return new RespJson(MicroResponseCode.SUCCESS.getResponseCode(), MicroResponseCode.SUCCESS.getResponseMessage());
    }

    /**
     * <h2>修改系统配置表详情</h2>
     * @param systemConfigBO  {@link SystemConfigBO} 系统配置表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @Override
    public RespJson editSystemConfig(SystemConfigBO systemConfigBO) {
        SystemConfig systemConfig = SystemConfigExtension.converEditSystemConfig(systemConfigBO);
        systemConfigMapper.updateByPrimaryKeySelective(systemConfig);
        return new RespJson(MicroResponseCode.SUCCESS.getResponseCode(),MicroResponseCode.SUCCESS.getResponseMessage());

    }

    /**
     * <h2>根据主键编号删除系统配置表信息</h2>
     * @param id  系统配置表 主键编号
     * @return  {@link RespJson} 返回结果基础类
     */

    @Override
    public RespJson deleteSystemConfig(Long id) {
        systemConfigMapper.deleteByPrimaryKey(id);
        return new RespJson(MicroResponseCode.SUCCESS.getResponseCode(),MicroResponseCode.SUCCESS.getResponseMessage());
    }

}
